<template>
	<div id="basicInformation">
		<!-- <el-descriptions content-class-name="my-content" :colon="false"> -->
		<el-descriptions>
			<template slot="title">
				<label style="margin-right:20px">
					{{ $t('member.center_wallet') }}
				</label>
				<el-button
					type="primary"
					icon="el-icon-refresh"
					:loading="refreshLoading"
					@click="refresh"
				>
					{{ $t('common.refresh') }}
				</el-button>
			</template>
			<!-- 现金钱包 -->
			<el-descriptions-item :label="$t('现金钱包余额')">
				{{ handleNumber(centralWallet.currency, centralWallet.cash) }}
			</el-descriptions-item>

			<el-descriptions-item
				:label="$t('member.withdrawal_frozen_balance')"
			>
				{{ handleNumber(centralWallet.currency, centralWallet.frozen) }}
			</el-descriptions-item>

			<el-descriptions-item :label="$t('局服务费冻结金额')">
				{{
					handleNumber(
						centralWallet.currency,
						centralWallet.texasFreezeAmount
					)
				}}
			</el-descriptions-item>
			<!-- <el-descriptions-item>
				<el-row>
					<el-col :span="5" style="margin-left: -10px;">
						<div class="wallet-list-box">
							<span>
								{{ $t('现金钱包余额') }}：
								{{
									handleNumber(
										centralWallet.currency,
										centralWallet.cash
									)
								}}
							</span>
							<span style="margin-top: 20px;">
								{{ $t('member.withdrawal_frozen_balance') }}：
								{{
									handleNumber(
										centralWallet.currency,
										centralWallet.frozen
									)
								}}
							</span>
						</div>
					</el-col>

					<el-col :span="12" style="margin-left:60px;">
						<el-descriptions>
							<el-descriptions-item
								v-for="(item, index) in gameBalanceWalletList"
								:key="index"
								:label="item.gameLabel"
							>
								{{
									handleNumber(
										centralWallet.currency,
										item.balance
									)
								}}
							</el-descriptions-item>
						</el-descriptions>
					</el-col>
					<el-col :span="7" style="float: right;">
						<el-button type="primary" @click="oneClickRecycling">
							{{ $t('member.one_click_recycling') }}
						</el-button>
					</el-col>
				</el-row>
			</el-descriptions-item> -->
		</el-descriptions>
		<el-divider></el-divider>
		<!-- 信用钱包 -->
		<template v-if="businessModel === 2">
			<el-descriptions>
				<template slot="title">
					<label style="margin-right:20px">
						{{ $t('member.credit_wallet') }}
					</label>
					<el-button
						type="primary"
						icon="el-icon-refresh"
						:loading="refreshLoading"
						@click="refresh"
					>
						{{ $t('common.refresh') }}
					</el-button>
				</template>
				<el-descriptions-item :label="$t('member.credit_balance')">
					{{
						handleNumber(
							centralWallet.currency,
							creditWallet.creditAvailable
						)
					}}
				</el-descriptions-item>

				<el-descriptions-item :label="$t('report.credit_limit')">
					{{
						handleNumber(
							centralWallet.currency,
							creditWallet.creditTotal
						)
					}}
				</el-descriptions-item>

				<el-descriptions-item :label="$t('report.payable_accounts')">
					{{
						handleNumber(
							centralWallet.currency,
							creditWallet.returnLoan
						)
					}}
				</el-descriptions-item>
			</el-descriptions>
			<el-divider />
		</template>
		<!-- 提现信息 -->
		<template>
			<el-descriptions
				:title="`${$t('member.withdrawal_info')}`"
				:column="3"
			>
				<template v-if="withdrawalInfo.withdrawLimitType === 1">
					<el-descriptions-item
						:label="$t('member.withdrawal_limit_type')"
					>
						账单限制
					</el-descriptions-item>
					<el-descriptions-item label="剩余可提现金额">
						{{toFixedNoRounding(withdrawalInfo.withdrawRemainAmount, 4)}}
					</el-descriptions-item>
				</template>
				<template v-if="withdrawalInfo.withdrawLimitType === 2">
					<el-descriptions-item
						:label="$t('member.withdrawal_limit_type')"
					>
						流水限制
					</el-descriptions-item>
					<el-descriptions-item
						:label="$t('member.need_effective_water')"
						:span="2"
					>
						<span>
							{{
								toFixedNoRounding(withdrawalInfo.validBillAmount, 4)
							}}
						</span>
						<span style="margin-left:5px;">
							<el-link
								v-if="hasPermission('90150034')"
								type="primary"
								:underline="false"
								@click="showAdjustForm"
							>
								{{ $t('member.person_adjust') }}
							</el-link>
						</span>
					</el-descriptions-item>

					<el-descriptions-item
						:label="$t('member.withdrawal_water_adjust')"
					>
						<span>
							{{
								toFixedNoRounding(withdrawalInfo.totalAdjust, 4)
							}}
						</span>
						<span style="margin-left:5px;">
							<el-link
								type="primary"
								:underline="false"
								@click="showAdjustList"
							>
								{{ $t('common.check_detail') }}
							</el-link>
						</span>
					</el-descriptions-item>

					<el-descriptions-item
						:label="$t('member.finish_det_onWater')"
					>
						{{
							toFixedNoRounding(withdrawalInfo.completeBillAmount, 4)
						}}
					</el-descriptions-item>

					<el-descriptions-item
						:label="$t('member.water_start_count_time')"
					>
						{{ withdrawalInfo.billStartTime }}
					</el-descriptions-item>
				</template>
			</el-descriptions>
			<el-divider></el-divider>

			<!-- 充提信息 -->
			<el-descriptions :title="`${$t('member.recharge_information')}`">
				<el-descriptions-item :label="$t('member.total_deposit')">
					{{
						handleNumber(
							centralWallet.currency,
							overdraftInfo.depositTotal
						)
					}}
				</el-descriptions-item>
				<el-descriptions-item :label="$t('member.total_deposit_num')">
					{{ overdraftInfo.depositTimes }}
				</el-descriptions-item>
				<el-descriptions-item :label="$t('member.last_deposit')">
					{{
						handleNumber(
							centralWallet.currency,
							overdraftInfo.lastDeposit
						)
					}}
				</el-descriptions-item>
				<el-descriptions-item :label="$t('member.total_withdraw')">
					{{
						handleNumber(
							centralWallet.currency,
							overdraftInfo.withdrawTotal
						)
					}}
				</el-descriptions-item>
				<el-descriptions-item
					:label="$t('member.total_big_withdraw_num')"
				>
					{{ overdraftInfo.withdrawTimes }}
					({{ $t('member.ordinary')
					}}{{ overdraftInfo.ordinaryWithdrawTimes
					}}{{ $t('member.second') }}，{{ $t('member.large')
					}}{{ overdraftInfo.bigWithdrawTimes
					}}{{ $t('member.second') }})
				</el-descriptions-item>
			</el-descriptions>

			<el-divider></el-divider>
		</template>
		<!-- 投注信息 -->
		<el-descriptions :title="`${$t('member.betting_information')}`">
			<el-descriptions-item :label="$t('member.bet_amount')">
				{{
					handleNumber(
						centralWallet.currency,
						playerBetInfo.betAmount
					)
				}}
			</el-descriptions-item>
			<el-descriptions-item :label="$t('member.net_amount')">
				<span :style="handleNumberColor(playerBetInfo.netAmount)">
					{{
						handleNumber(
							centralWallet.currency,
							playerBetInfo.netAmount
						)
					}}
				</span>
			</el-descriptions-item>
			<el-descriptions-item :label="$t('member.company_net_amount')">
				<span
					:style="handleNumberColor(playerBetInfo.companyNetAmount)"
				>
					{{
						handleNumber(
							centralWallet.currency,
							playerBetInfo.companyNetAmount
						)
					}}
				</span>
			</el-descriptions-item>
			<el-descriptions-item :label="$t('member.return_water_amount')">
				{{
					handleNumber(
						centralWallet.currency,
						playerBetInfo.returnWaterAmount
					)
				}}
			</el-descriptions-item>
		</el-descriptions>

		<el-divider></el-divider>
		<!-- top3场馆数据 -->
		<el-descriptions content-class-name="my-content" :colon="false">
			<template slot="title">
				<label style="margin-right:20px">
					{{ $t('member.top_3_platforms') }}
				</label>
				<el-button
					type="primary"
					icon="el-icon-refresh"
					:loading="winloseLoading"
					@click="getTopPlayerList(1)"
				>
					{{ $t('member.win_or_lose') }}
				</el-button>
				<el-button
					type="primary"
					icon="el-icon-refresh"
					:loading="bettingLoading"
					@click="getTopPlayerList(2)"
				>
					{{ $t('member.betting') }}
				</el-button>
			</template>
			<el-descriptions-item>
				<el-table
					v-if="topPlayerFlag"
					border
					v-loading="winloseLoading"
					element-loading-spinner="el-icon-loading"
					size="mini"
					:data="topPlayerList"
					:header-row-style="{ height: '24px', lineHeight: '24px' }"
					style="margin: 10px 0 30px 0; z-index: 0"
					:header-cell-style="getRowClass"
					highlight-current-row
				>
					<el-table-column
						align="center"
						prop="gameName"
						:label="$t('member.blue_color')"
					>
						<template slot-scope="scope">
							<span class="blueColor">
								<!-- 此处原型改为场馆，接口目前返回的还是平台，沟通过后端middle，说前期先不改 -->
								{{ scope.row.gameName }}
							</span>
						</template>
					</el-table-column>
					<el-table-column
						prop="netAmount"
						align="center"
						:label="$t('member.members_win_or_lose')"
					>
						<template slot-scope="scope">
							<span
								:style="handleNumberColor(scope.row.netAmount)"
							>
								{{
									handleNumber(
										scope.row.currency,
										scope.row.netAmount
									)
								}}
							</span>
						</template>
					</el-table-column>
					<el-table-column
						prop="betAmount"
						align="center"
						:label="$t('member.betting_amount')"
					>
						<template slot-scope="scope">
							{{
								handleNumber(
									scope.row.currency,
									scope.row.betAmount
								)
							}}
						</template>
					</el-table-column>
					<el-table-column
						prop="validBetAmount"
						align="center"
						:label="$t('member.effective_betting')"
					>
						<template slot-scope="scope">
							{{
								handleNumber(
									scope.row.currency,
									scope.row.validBetAmount
								)
							}}
						</template>
					</el-table-column>
				</el-table>
				<el-table
					v-else
					border
					size="mini"
					v-loading="bettingLoading"
					element-loading-spinner="el-icon-loading"
					:data="topPlayerList"
					:header-row-style="{ height: '24px', lineHeight: '24px' }"
					style="margin: 10px 0 30px 0; z-index: 0"
					:header-cell-style="getRowClass"
				>
					<el-table-column
						align="center"
						prop="gameName"
						:label="$t('member.blue_color')"
					>
						<template slot-scope="scope">
							<span class="blueColor">
								{{ scope.row.gameName }}
							</span>
						</template>
					</el-table-column>
					<el-table-column
						prop="betAmount"
						align="center"
						:label="$t('member.betting_amount')"
					>
						<template slot-scope="scope">
							{{
								handleNumber(
									scope.row.currency,
									scope.row.betAmount
								)
							}}
						</template>
					</el-table-column>
					<el-table-column
						prop="validBetAmount"
						align="center"
						:label="$t('member.effective_betting')"
					>
						<template slot-scope="scope">
							{{
								handleNumber(
									scope.row.currency,
									scope.row.validBetAmount
								)
							}}
						</template>
					</el-table-column>
					<el-table-column
						prop="netAmount"
						align="center"
						:label="$t('member.members_win_or_lose')"
					>
						<template slot-scope="scope">
							<span
								:style="handleNumberColor(scope.row.netAmount)"
							>
								{{
									handleNumber(
										scope.row.currency,
										scope.row.netAmount
									)
								}}
							</span>
						</template>
					</el-table-column>
				</el-table>
			</el-descriptions-item>
		</el-descriptions>

		<!--人工调整流水-->
		<el-dialog
			:title="$t('member.water_person_adjust')"
			:visible.sync="adjustVisible"
			width="500px"
			center
			:close-on-click-modal="true"
			:destroy-on-close="true"
			:before-close="handleCloseAdjust"
			@close="handleCloseAdjust"
		>
			<el-form ref="adjustForm" :model="adjustForm" label-width="100px">
				<el-form-item
					:label="`${$t('member.adjust_type')}:`"
					prop="adjustType"
					:rules="[
						{
							required: true,
							message: $t('common.please_choose'),
							trigger: 'blur'
						}
					]"
				>
					<el-select
						v-model="adjustForm.adjustType"
						:placeholder="$t('common.please_choose')"
					>
						<el-option label="增加" value="1"></el-option>
						<el-option label="扣除" value="2"></el-option>
					</el-select>
				</el-form-item>

				<el-form-item
					:label="`${$t('member.adjust_num')}:`"
					prop="amount"
					:rules="[
						{
							required: true,
							message: $t('common.please_enter'),
							trigger: 'blur'
						}
					]"
				>
					<el-input
						v-input="{ name: 'float', num: '4' }"
						v-model.trim="adjustForm.amount"
						clearable
						@input="onInputAmount"
					></el-input>
				</el-form-item>

				<el-form-item
					:label="`${$t('member.submit_comments')}:`"
					prop="remark"
					:rules="[
						{
							required: true,
							message: $t('member.please_enter_remarks'),
							trigger: 'blur'
						}
					]"
				>
					<el-input
						v-model.trim="adjustForm.remark"
						type="textarea"
						maxlength="500"
						rows="3"
						show-word-limit
						clearable
					></el-input>
				</el-form-item>
			</el-form>

			<div slot="footer" class="dialog-footer">
				<el-button @click="handleCloseAdjust">
					{{ $t('common.cancel') }}
				</el-button>
				<el-button
					type="primary"
					:disabled="submitAdjustLoading"
					@click="submitAdjust"
				>
					{{ $t('common.sure') }}
				</el-button>
			</div>
		</el-dialog>
		<!--人工调整流水明细-->
		<el-dialog
			v-if="adjustListVisible"
			:visible.sync="adjustListVisible"
			width="650px"
			center
			:close-on-click-modal="true"
			:destroy-on-close="true"
			:before-close="handleCloseAdjustList"
			@close="handleCloseAdjustList"
		>
			<el-table
				v-loading="adjustListLoading"
				element-loading-spinner="el-icon-loading"
				border
				size="mini"
				class="small-size-table"
				:data="adjustList"
				style="width: 100%"
				:header-cell-style="getRowClass"
			>
				<el-table-column
					prop="changeAmount"
					align="center"
					label="调整金额"
					min-width="120"
				>
					<template slot-scope="scope">
						<span
							:style="handleNumberColor(scope.row.changeAmount)"
						>
							{{
								toFixedNoRounding(scope.row.changeAmount, 4)
							}}
						</span>
					</template>
				</el-table-column>
				<el-table-column
					prop="createdAt"
					align="center"
					label="调整时间"
					min-width="120"
				></el-table-column>
				<el-table-column
					prop="adjustOperator"
					align="center"
					label="调整操作人"
					min-width="120"
				></el-table-column>
			</el-table>
			<div v-if="totalAdjustPage > 1" slot="footer" class="dialog-footer">
				<el-pagination
					v-show="!!totalAdjustCount"
					:current-page.sync="pageNum"
					background
					layout="total, sizes,prev, pager, next, jumper"
					:page-size.sync="pageSize"
					:page-sizes="pageSizes"
					:total="totalAdjustCount"
					:pager-count="9"
					@current-change="handleCurrentChange"
					@size-change="handleSizeChange"
				></el-pagination>
			</div>
		</el-dialog>
		<GoogleKeyInput
			:isShowdialog="isShowGoogleKey"
			@getGoogleKey="submitGoogleKey($event)"
			@backPrevStep="closeGoogleKey()"
		></GoogleKeyInput>
	</div>
</template>
<script>
import list from '@/mixins/list'
export default {
	components: {
		GoogleKeyInput: () => import('@/components/GoogleKeyInput')
	},
	mixins: [list],
	props: {
		parentData: { type: Object, default: () => ({}) }
	},
	data() {
		return {
			isShowGoogleKey: false,
			// centerWallet: {}, // 中心钱包
			// balanceAllList: [], // 所有场馆余额
			// showButton: true,
			overdraftInfo: {}, // 充提信息
			centralWallet: {}, // 中心钱包
			creditWallet: {}, // 信用钱包
			withdrawalInfo: {}, // 提现信息
			playerBetInfo: {}, // 投注信息
			topPlayerList: [], // top前3场馆统计
			topPlayerFlag: true,
			refreshLoading: false, // 加载刷新
			winloseLoading: false,
			bettingLoading: false,
			adjustForm: {
				adjustType: '1',
				amount: undefined,
				remark: undefined
			}, // 流水调整信息
			submitAdjustLoading: false,
			adjustVisible: false,
			adjustList: [], // 调整记录列表
			totalAdjustCount: 0,
			totalAdjustPage: 0,
			adjustListLoading: false,
			adjustListVisible: false
			// gameBalanceWalletList: [
			// 	// 各场馆钱包
			// 	{
			// 		gameCode: 'cp', // 彩票钱包
			// 		gameLabel: this.$t('member.dxn_lottery_wallet'),
			// 		balance: undefined
			// 	},
			// 	{
			// 		gameCode: 'zr', // 真人钱包
			// 		gameLabel: this.$t('member.dxn_real_person_wallet'),
			// 		balance: undefined
			// 	},
			// 	{
			// 		gameCode: 'ty', // 体育钱包
			// 		gameLabel: this.$t('member.dxn_sports_wallet'),
			// 		balance: undefined
			// 	},
			// 	{
			// 		gameCode: 'byqp', // 棋牌钱包
			// 		gameLabel: this.$t('member.dxn_chess_and_card_wallet'),
			// 		balance: undefined
			// 	},
			// 	{
			// 		gameCode: 'dj', // 电竞钱包
			// 		gameLabel: this.$t('member.dxn_esports_wallet'),
			// 		balance: undefined
			// 	}
			// ]
		}
	},
	computed: {
		businessModel() {
			return this.parentData?.businessModel
		}
	},
	watch: {},
	created() {
		this.refreshLoading = true
		Promise.all([
			this.getCentralAndCreditWallet(),
			this.getPlayerBetInfo(),
			this.getTopPlayerList(1)
		]).finally(() => {
			this.refreshLoading = false
		})
	},
	methods: {
		onInputAmount(val) {
			// 最大值不能超过10位,超出10位默认为最大值
			if (!isNaN(Number(val)) && Number(val) > 10000000000) {
				this.adjustForm.amount = 9999999999.99
			}
		},
		closeGoogleKey() {
			this.isShowGoogleKey = false
		},
		submitGoogleKey(googleVerifyCode) {
			this.isShowGoogleKey = false
			this.submitAdjustLoading = true
			this.adjustForm.merchantId = this.parentData.merchantId
			this.adjustForm.memberId = this.parentData.userId
			this.adjustForm.amount = Number(this.adjustForm.amount)
			this.adjustForm.googleVerifyCode = googleVerifyCode
			this.$api
				.setMemberFlowAdjust(this.adjustForm)
				.then((res) => {
					if (res.code === 200) {
						this.$message.success(this.$t('common.save_success'))
						this.adjustVisible = false
						this.getCentralAndCreditWallet()
					}
				})
				.catch(() => {})
				.finally(() => {
					this.submitAdjustLoading = false
				})
		},
		// 所需流水-人工调整
		submitAdjust() {
			this.$refs.adjustForm.validate((valid) => {
				if (Number(this.adjustForm.amount) <= 0) {
					return this.$message.warning('调整数量不能为0')
				}
				if (valid) {
					this.isShowGoogleKey = true
				}
			})
		},
		// 所需流水-人工调整明细
		showAdjustList() {
			this.adjustListVisible = true
			this.getAdjustList()
		},
		handleSizeChange(value) {
			this.pageNum = 1
			this.pageSize = value
			this.getAdjustList()
		},
		handleCurrentChange(value) {
			this.pageNum = value
			this.getAdjustList()
		},
		getAdjustList() {
			this.adjustListLoading = true
			// this.adjustList = []
			const params = {
				merchantId: this.parentData.merchantId,
				userId: this.parentData.userId,
				...this.getParams(params)
			}
			this.$api
				.getMemberFlowAdjustList(params)
				.then((res) => {
					if (res.code === 200) {
						this.adjustList = res?.data?.record || []
						this.totalAdjustCount = res?.data?.totalRecord || 0
						this.totalAdjustPage = res?.data?.totalPage || 0
					}
				})
				.catch(() => {})
				.finally(() => {
					this.adjustListLoading = false
				})
		},
		showAdjustForm() {
			this.submitAdjustLoading = false
			this.adjustVisible = true
		},
		handleCloseAdjust() {
			this.adjustForm = {
				adjustType: '1', // 1:增加，2:扣除
				amount: undefined,
				remark: undefined
			}
			this.adjustVisible = false
		},
		handleCloseAdjustList() {
			this.adjustListVisible = false
		},
		// 一键回收至中心钱包
		oneClickRecycling(val) {
			// 提示信息: </br><span style='font-size:12px;color:#c1c1c1'>
			// ${this.$t('member.frozen_amount_tips')}</span>
			this.$confirm(
				`<strong>${this.$t('member.recycle_tips')}</strong>`,
				this.$t('member.confirmation_prompt'),
				{
					dangerouslyUseHTMLString: true,
					confirmButtonText: this.$t('common.confirm'),
					cancelButtonText: this.$t('common.cancel'),
					type: 'warning'
				}
			)
				.then(() => {
					this.$api
						.getOneKeyWithdraw({ ...this.parentData })
						.then((res) => {
							if (res.code === 200) {
								this.refresh()
								this.$message({
									type: 'success',
									message: this.$t(
										'member.recycling_succeeded'
									)
								})
							}
						})
						.catch(() => {})
				})
				.catch(() => {})
		},
		// 查询中心钱包, 各场馆钱包余额, 信用钱包
		async getCentralAndCreditWallet() {
			await this.$api
				.getMemberDetailBalance({
					...this.parentData
				})
				.then((res) => {
					if (res.code === 200) {
						this.formatMemberDetailBalance(res)
					} else {
						this.$message.error(res.msg)
					}
				})
				.catch(() => {})
		},
		// 处理后端传过来的数据
		formatMemberDetailBalance(res) {
			const {
				currency, // 币种
				cash, // 中心钱包余额
				frozen, // 提现冻结余额
				creditAvailable, // 信用钱包余额
				creditTotal, // 信用额度
				returnLoan, // 应收账款
				texasFreezeAmount, // 局服务费冻结金额
				withdrawLimitInfo = {}, // 提现信息
				depositWithdrawSummaryDTO = {} // 充提信息
			} = res?.data || {}
			// 中心钱包
			this.centralWallet = {
				currency: currency,
				cash: cash,
				frozen: frozen,
				texasFreezeAmount: texasFreezeAmount
			}
			// 各游戏场馆钱包余额
			// const gameBalanceInfos = Array.isArray(res.data?.gameBalanceInfos)
			// 	? res.data.gameBalanceInfos
			// 	: []
			// this.gameBalanceWalletList.forEach((item) => {
			// 	item.balance =
			// 		gameBalanceInfos.find((row) => {
			// 			return row.gameCode === item.gameCode
			// 		})?.balance || 0
			// })
			// 信用钱包
			this.creditWallet = {
				creditAvailable: creditAvailable,
				creditTotal: creditTotal,
				returnLoan: returnLoan
			}
			// 提现信息
			this.withdrawalInfo = {
				billStartTime: withdrawLimitInfo.billStartTime || 0, // 流水开始时间
				completeBillAmount: withdrawLimitInfo.completeBillAmount || 0, // 已完成有效流水
				userId: withdrawLimitInfo.userId || 0, // 用户id
				userType: withdrawLimitInfo.userType || 0, // 用户类型
				validBillAmount: withdrawLimitInfo.validBillAmount || 0, // 所需有效流水
				withdrawLimitType: withdrawLimitInfo.withdrawLimitType || 0, // 取款限制类型：1账单，2流水
				totalAdjust: withdrawLimitInfo.totalAdjust || 0, // 取款流水调整
				withdrawRemainAmount:
					withdrawLimitInfo.withdrawRemainAmount || 0 // 剩余可提现金额
			}
			// 充提信息
			this.overdraftInfo = {
				bigDepositTimes: depositWithdrawSummaryDTO.bigDepositTimes || 0, // 大额存款次数
				bigWithdrawTimes:
					depositWithdrawSummaryDTO.bigWithdrawTimes || 0, // 大额取款次数
				depositTimes: depositWithdrawSummaryDTO.depositTimes || 0, // 存款次数
				depositTotal: depositWithdrawSummaryDTO.depositTotal || 0, // 存款总额
				lastDeposit: depositWithdrawSummaryDTO.lastDeposit || 0, // 最近一笔存款
				lastWithdraw: depositWithdrawSummaryDTO.lastWithdraw || 0, // 最近一笔取款
				withdrawTimes: depositWithdrawSummaryDTO.withdrawTimes || 0, // 总的取款次数
				withdrawTotal: depositWithdrawSummaryDTO.withdrawTotal || 0 // 取款总额
			}

			this.overdraftInfo.ordinaryWithdrawTimes =
				Number(this.overdraftInfo.withdrawTimes) -
				Number(this.overdraftInfo.bigWithdrawTimes)
		},
		// 投注信息查询
		async getPlayerBetInfo(val) {
			await this.$api
				.getPlayerBetHistorySum({
					...this.parentData
				})
				.then((res) => {
					if (res.code === 200) {
						const {
							betAmount = 0,
							netAmount = 0,
							companyNetAmount = 0,
							returnWaterAmount = 0
						} = res?.data || {}
						this.playerBetInfo = {
							betAmount: betAmount,
							netAmount: netAmount,
							companyNetAmount: companyNetAmount,
							returnWaterAmount: returnWaterAmount
						}
					}
				})
				.catch(() => {})
		},
		// top前3场馆统计
		async getTopPlayerList(val) {
			this.topPlayerFlag = val === 1
			this.topPlayerList = []
			if (val === 1) {
				this.winloseLoading = true
			}
			if (val === 2) {
				this.bettingLoading = true
			}
			await this.$api
				.getPlayerTop3({ orderKey: val, ...this.parentData })
				.then((res) => {
					this.topPlayerList = res?.data || []
				})
				.catch(() => {})
				.finally(() => {
					if (val === 1) {
						this.winloseLoading = false
					}
					if (val === 2) {
						this.bettingLoading = false
					}
				})
		},

		 toFixedNoRounding(num, precision = 4) {
				const parts = num.toString().split('.')
				if (parts.length === 1)
				{
					if (parts[0].indexOf('-') !== -1) {
						const str1 = parts[0].replace(/\-/g, '')
						if(str1 === '0')
							return '$' + str1.toString()
						else
							return '-$' + str1.toString()
					}
					else
						return '$' + parts[0].toString()
				}
				// 截取小数点前和小数点后的部分
				let integerPart = parts[0]
				const decimalPart = parts[1]
				// 截取指定位数的小数部分
				const newDecimal = decimalPart.slice(0, precision);
				// 拼接结果
				if (parts[0].indexOf('-') !== -1) {
					let str1 = integerPart.replace(/\-/g, '')
					str1 = str1.replace(/\B(?=(\d{3})+(?!\d))/g, ",")
					return '-$' + str1 + '.' + newDecimal
				}
				else
				{
					let str1 = integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, ",")
					return '$' + str1 + '.' + newDecimal
				}
		},

		async refresh() {
			this.refreshLoading = true
			return Promise.all([
				this.getCentralAndCreditWallet(),
				this.getPlayerBetInfo()
			]).finally(() => {
				this.refreshLoading = false
			})
		}
		// 一键查询所有场馆余额
		// getOneKeyBalance(val) {
		// 	this.$api
		// 		.getOneKeyBalance({
		// 			...this.parentData
		// 		})
		// 		.then((res) => {
		// 			if (res.code === 200) {
		// 				this.balanceAllList = res?.data
		// 				this.showButton = this.balanceAllList.length === 0
		// 			}
		// 		})
		// 		.catch(() => {})
		// },
		// 提现流水查询
		// async getWithdrawWater(val) {
		// 	await this.$api
		// 		.getWithdrawWater({
		// 			...this.parentData
		// 		})
		// 		.then((res) => {
		// 			if (res.code === 200) {
		// 				this.withdrawalList = res?.data || {}
		// 			}
		// 		})
		// },
		// async query() {
		// 	await this.$api
		// 		.getAccountCashAccount({ ...this.parentData })
		// 		.then((res) => {
		// 			this.centerWallet = res?.data || {}
		// 		})
		// 		.catch(() => {})
		// 	await this.$api
		// 		.getOutlineInfo({ ...this.parentData })
		// 		.then((res) => {
		// 			this.overdraftList = res?.data || {}
		// 		})
		// 		.catch(() => {})
		// },
	}
}
</script>
<style lang="scss" scoped>
::v-deep .my-content {
	width: 100%;
	display: flex;
	align-items: center;
	margin-bottom: 50px;
	.wallet-list-box {
		flex: 0.5;
		height: 100%;
		display: flex;
		flex-direction: column;
		justify-content: space-around;
		border-right: 1px solid #ccc;
	}
	.wallet-all {
		flex: 2.5;
		min-height: 92px;
		line-height: 92px;
		padding-left: 40px;
	}
	.wallet-list {
		flex: 2.5;
		display: flex;
		flex-wrap: wrap;
		> li {
			line-height: 32px;
			margin-right: 60px;
			button {
				padding: 0;
			}
		}
	}
}

.vi_VN,
.en_US,
.th_TH {
	.my-content .wallet-list-box {
		flex: 2;
	}
}
</style>
